package reflection;

public class test7 {
    public static void main(String[] args) throws ClassNotFoundException {
        //获取系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);
        //获取扩展类加载器，扩展类加载器是系统类加载器的父类加载器
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);
        //获取根加载器，根加载器是扩展类加载器的父类
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);

        //获取当前类由哪个类加载器加载
        ClassLoader classLoader = Class.forName("reflection.test7").getClassLoader();
        System.out.println(classLoader);

        //测试JDK内部类由哪个加载器加载
        ClassLoader classLoader1 = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(classLoader1);

        //如何获得系统类加载器可以加载哪些类或者jar包
        System.out.println(System.getProperty("java.class.path"));
    }
}
